#region Copyright (c) 2003 - 2006 Toenda Software Development
/*
 * Copyright (c) 2003 - 2006 Toenda Software Development
 */
#endregion

using MSSystem = System;
using System.Data;
using System.Collections;
using System.Text;
using Toenda.Rails.Data;
using Toenda.Rails.DataContainer;

namespace Toenda.Rails {
	namespace System {
		/// <summary>
		/// Class Tools
		/// </summary>
		public class Tools {
			/// <summary>
			/// Default constructor
			/// </summary>
			public Tools() {
			}

			/// <summary>
			/// Get the version af the assembly
			/// </summary>
			/// <returns></returns>
			public string GetAssemblyVersion() {
				return MSSystem.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
			}

			/// <summary>
			/// Convert a page integer to the startimage
			/// </summary>
			/// <param name="page"></param>
			/// <returns></returns>
			public int ConvertPageToStartValue(int page) {
				return this.ConvertPageToStartValue(page, 20);
			}

			/// <summary>
			/// Convert a page integer to the startimage
			/// </summary>
			/// <param name="page"></param>
			/// <returns></returns>
			public int ConvertPageToStartValue(int page, int valueperpage) {
				double vpp = MSSystem.Convert.ToDouble(valueperpage) / 2;
				double ret = 0;

				if(page == 1) {
					return 0;
				}
				else {
					ret = page * vpp + ((page - 2) * vpp);

					ret = MSSystem.Math.Round(ret, 0);

					return MSSystem.Convert.ToInt32(ret);
				}
			}
		}
	}
}
